home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / J-M / MH Power Scripts v1.3.cpt / MH Power Scripts v1.3 / card_10225.txt < prev    next >
Text File  |  1989-02-26  |  7KB  |  216 lines

  1. -- card: 10225 from stack: in.3
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2663
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 00
  10. -- high flags: A004
  11. -- rect: left=287 top=33 right=70 bottom=447
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: Easy Text Import
  20. ----- HyperTalk script -----
  21. on copyright
  22.  
  23.   -- Easy Text Import, Copyright by Mac Help Co., January 1988
  24.   -- by Chris Hostetter, Mac Help Co., 1800 East Market Street
  25.   -- Long Beach, CA  90805, (213) 428-7414
  26.   --      The script for this button is copyrighted and may not be
  27.   --      used without the written permission of the author (above).
  28.  
  29. end copyright
  30.  
  31.  
  32. on mouseUp
  33.   Global THISDATA, ThisFile
  34.  
  35.   ask "The TEXT file and this STACK program must be in the same" && "folder or on the same level!" & Return & Return & "Name of the TEXT file to import?" with ThisFile
  36.  
  37.   if it is empty then exit mouseUp
  38.   put it into ThisFile
  39.   open file ThisFile
  40.   put true into SkipLines
  41.   put true into FirstImport
  42.   put 1 into ShowEveryFew
  43.   put 10 into WhenToShow
  44.   put 0 into NxtLn
  45.   put empty into PutDataHere
  46.  
  47.   answer "Read data into a VARIABLE, an EXISTING field, or a NEW field?" with "Variable" or "Existing" or "New"
  48.  
  49.   if it is "Variable" then
  50.     answer "Data will be READ into the Global Variable: 'THISDATA'"
  51.     put quote & "THISDATA" & quote into PutDataHere
  52.   else
  53.     if it is "Existing" then
  54.       if the number of background fields is 0 and the number of card fields is 0 then
  55.         answer "Put Data into a Field or Variable?" with "Variable"
  56.       end if
  57.       if the number of background fields > 0 and the number of card fields is 0 then
  58.         answer "Put Data into a Field or Variable?" with "Background" or "Variable"
  59.       end if
  60.       if the number of background fields is 0 and the number of card fields > 0 then
  61.         answer "Put Data into a Field or Variable?" with "Card" or "Variable"
  62.       end if
  63.       if the number of background fields > 0 and the number of card fields > 0 then
  64.         answer "Put Data into a Field or Variable?" with "Background" or "Card" or "Variable"
  65.       end if
  66.  
  67.       if it is "Background" then
  68.         repeat with i = 1 to the number of background fields
  69.           ask "Read DATA into Bkgnd Field" && i && "of" && the number of Bkgnd fields with the name of background field i
  70.           if it is not empty then
  71.             put it into PutDataHere
  72.             exit repeat
  73.           end if
  74.         end repeat
  75.       end if
  76.       if it is "Card" then
  77.         repeat with i = 1 to the number of card fields
  78.           ask "Read DATA into Card Field" && i && "of" && the number of card fields with the name of card field i
  79.           if it is not empty then
  80.             put it into PutDataHere
  81.             exit repeat
  82.           end if
  83.         end repeat
  84.       end if
  85.  
  86.     else
  87.       set lockscreen to true
  88.       -- CREATE A NEW FIELD, BUT CHECK IT OUT
  89.       put the userlevel into OldUserLevel
  90.       set userlevel to 5
  91.       set lockscreen to true
  92.       put the number of card fields into TotalFields
  93.       doMenu "New Field"
  94.       put the number of card fields into NewTotalFields
  95.       set the userlevel to OldUserLevel
  96.       if TotalFields is NewTotalFields then
  97.         answer "Couldn't creat a field, data will be READ into the Global Variable: THISDATA"
  98.         put quote & "THISDATA" & quote into PutDataHere
  99.       else
  100.         set the name of card field NewTotalFields to "This Data"
  101.         set the style of card field NewTotalFields to "Scrolling"
  102.         set the textfont of card field NewTotalFields to "Monaco"
  103.         set the textSize of card field NewTotalFields to 9
  104.         choose browse tool
  105.         set the rect of card field NewTotalFields to 4,69,508,290
  106.         put "Card field" && quote & "This Data" & quote into PutDataHere
  107.         set lockscreen to false
  108.         set lockscreen to false
  109.       end if
  110.     end if
  111.   end if
  112.  
  113.   if PutDataHere is empty then
  114.     beep
  115.     answer "No field selected!  You might want to try 'NEW' to" && "automatically create a new field for you!"
  116.     close file ThisFile
  117.     exit mouseUp
  118.   end if
  119.  
  120.   --ask "This is the selected location" with PutDataHere
  121.   if PutDataHere contains "Field" then
  122.     do "set the style of" && PutDataHere && "to Scrolling"
  123.     do "get the rect of" && PutDataHere
  124.     put item 4 of it - item 2 of it into PageFull
  125.     put the round of (PageFull - (PageFull/2)) into PageFull
  126.     put 0 into ThisScroll
  127.   end if
  128.  
  129.   set cursor to 4
  130.   repeat forever
  131.     read from file ThisFile until return
  132.     put it into ThisLine
  133.  
  134.     if SkipLines is true then
  135.       repeat forever
  136.         --put char 1 to 36 of it into it
  137.         --put "..." after it
  138.         if it is empty then put "*** NO DATA FOUND ***  Hit the SKIP" && "LINE button, or CANCEL and re-check the name of the" && "data file!" into it
  139.         add 1 to Nxtln
  140.         answer "Begin IMPORT at line" && NxtLn && "or skip this line?" && Return & Return & it with CANCEL or "Skip Line" or "Do IMPORT"
  141.         if it is "Cancel" then
  142.           close file ThisFile
  143.           exit mouseUp
  144.         end if
  145.         if it is "Skip Line" then
  146.           read from file ThisFile until return
  147.           put it into ThisLine
  148.         else
  149.           put false into SkipLines
  150.           set lockscreen to true
  151.           exit repeat
  152.         end if
  153.         if ThisLine is empty then
  154.           close file ThisFile
  155.           exit mouseUp
  156.         end if
  157.       end repeat
  158.     end if
  159.  
  160.     if ThisLine is empty then exit repeat
  161.  
  162.     do "put ThisLine after" && PutDataHere
  163.     add 1 to Nxtln
  164.     set cursor to 4
  165.  
  166.     -- LOCK & UNLOCK SCREEN TO SHOW STATUS EVERY SO OFTEN
  167.     add 1 to ShowEveryFew
  168.     if PutDataHere contains "field" then
  169.       if the value of ShowEveryFew ‚â• WhenToShow then
  170.         set lockscreen to false
  171.         put 0 into ShowEveryFew
  172.         set lockscreen to true
  173.         add PageFull to ThisScroll
  174.         do "set the scroll of" && PutDataHere && "to ThisScroll"
  175.       end if
  176.     end if
  177.  
  178.   end repeat
  179.  
  180.   close file ThisFile
  181. end mouseUp
  182.  
  183.  
  184. -- part 20 (field)
  185. -- low flags: 00
  186. -- high flags: 0007
  187. -- rect: left=269 top=76 right=290 bottom=506
  188. -- title width / last selected line: 0
  189. -- icon id / first selected line: 0 / 0
  190. -- text alignment: 0
  191. -- font id: 4
  192. -- text size: 9
  193. -- style flags: 0
  194. -- line height: 10
  195. -- part name: Scrolling Field
  196.  
  197.  
  198. -- part contents for background part 8
  199. ----- text -----
  200. Card 7 of 20
  201.  
  202. -- part contents for background part 9
  203. ----- text -----
  204. EASY TEXT IMPORT
  205.  
  206. This button will import a text file.  It will ask if you want to import the text file three different ways:
  207.  
  208. 1.  To a global variable (for use later)
  209.  
  210. 2.  To an existing field, it will check to see if you have any existing background and/or card fields on the current card, and if any exist, it will let you select which one you want to use.
  211.  
  212. 3.  And finally, you can select NEW in which case it will make a new scrolling card field and it will read the data right into that field.
  213.  
  214.  
  215.  
  216.